Understanding the tools that extend CSS with programming features
A CSS preprocessor is a scripting language that extends the default capabilities of CSS. It allows developers to write code in the preprocessor's syntax, which is then compiled into regular CSS that browsers can understand.
Preprocessors introduce features not available in vanilla CSS, such as:
Here's a simple example showing SCSS syntax and its compiled CSS output:
$primary-color: #ff7b00;
.container {
padding: 20px;
.heading {
color: $primary-color;
font-size: 24px;
}
p {
margin-bottom: 10px;
}
}
.container {
padding: 20px;
}
.container .heading {
color: #ff7b00;
font-size: 24px;
}
.container p {
margin-bottom: 10px;
}